from decimal import Decimal
st={'F0001':{'name':'苹果','price':1.2},
     'F0002':{'name':'香蕉','price':5.5},
     'F0003':{'name':'梨','price':1.5},
     'F0004':{'name':'橘子','price':3.4}}
buyst={}
user=input("请输入用户名：")
passward=input("请输入密码:")
print("1:查看商品信息和已购买信息")
print("2:购买商品")
print("exit:退出并打印")
########查看商品信息
if user=="root" and passward=="123456":
    print("登陆成功")
    project = input("请输入操作： ")
    for i in project:
        if project=="1":
            print("商品信息为：")
            for i,j in st.items():
                print(f"编号：{i}")
                for m,n in j.items():
                    print(f"name:{m}")
                    print(f"price:{n}")
                    print(f"已购买信息为{buyst}")
        elif project=="2":
            money=1000
            print(f"您的余额为{money}")
            for i in range(100):
                num=input("请输入购买的商品编号：按0退出")
                if num in st.keys():
                    qua=int(input("请输入要购买的数量："))
                    money=money-float((st[num]["price"])*qua)
                    if money>=0:
                        print(f"余额充足，剩余{money}")
                        print(buyst)
                    else:
                        print("余额不足")
                else:
                    break
                    print("商品不存在")





